<?php

namespace app\admin\model;

use think\Model;
use traits\model\SoftDelete;

class Work extends Model
{

    use SoftDelete;

    

    // 表名
    protected $name = 'work';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [
        'audio_status_text',
        'video_status_text',
        'is_featured_text'
    ];
    

    
    public function getAudioStatusList()
    {
        return ['0' => __('Audio_status 0'), '1' => __('Audio_status 1'), '2' => __('Audio_status 2'), '-1' => __('Audio_status -1')];
    }

    public function getVideoStatusList()
    {
        return ['0' => __('Video_status 0'), '1' => __('Video_status 1'), '2' => __('Video_status 2'), '3' => __('Video_status 3'), '-1' => __('Video_status -1')];
    }

    public function getIsFeaturedList()
    {
        return ['0' => __('Is_featured 0'), '1' => __('Is_featured 1')];
    }


    public function getAudioStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['audio_status']) ? $data['audio_status'] : '');
        $list = $this->getAudioStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getVideoStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['video_status']) ? $data['video_status'] : '');
        $list = $this->getVideoStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsFeaturedTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_featured']) ? $data['is_featured'] : '');
        $list = $this->getIsFeaturedList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
